﻿using System;

namespace Storyteller.Framework
{
	public static class RandomUtil
	{
		private static readonly Random globalRandom = new Random();
		private static readonly object globalLock = new object();

		[ThreadStatic]
		private static Random localRandom = null;

		public static Random Random
		{
			get
			{
				if (localRandom == null)
				{
					lock (globalLock)
					{
						localRandom = new Random(globalRandom.Next());
					}
				}

				return localRandom;
			}
		}
	}
}
